package com.epu.itepu;

import java.text.SimpleDateFormat;

import com.epu.itepu.helper.Variables;
import com.epu.itepu.models.PhotoProperties;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class InfoActivity extends Activity {

	/** Called when the activity is first created. */
	private TextView txtName;
	private TextView txtLocation;
	private TextView txtType;
	private TextView txtTimeStamp;
	private TextView txtWidth;
	private TextView txtHeigh;
	private TextView txtLatitude;
	private TextView txtLongitude;
	
	@SuppressLint("SimpleDateFormat")
	SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
	

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.acitvity_info);
		
		this.txtName = (TextView) findViewById(R.id.txtName);
		this.txtLocation = (TextView) findViewById(R.id.txtLocation);
		this.txtType = (TextView) findViewById(R.id.txtType);
		this.txtTimeStamp = (TextView) findViewById(R.id.txtTimeStamp);
		this.txtWidth = (TextView) findViewById(R.id.txtWidth);
		this.txtHeigh = (TextView) findViewById(R.id.txtHeigh);
		this.txtLatitude = (TextView) findViewById(R.id.txtLatitude);
		this.txtLongitude = (TextView) findViewById(R.id.txtLongitude);
	
		
	}
	
	@Override
	protected void onResume(){
		super.onResume();
		
		PhotoProperties currentPhoto = Variables.listProperties.get(Variables.currentIndex);
		
		this.txtName.setText(currentPhoto.getName());
		this.txtLocation.setText(currentPhoto.getLocation());
		this.txtType.setText(currentPhoto.getType());
		if (currentPhoto.getTimeStamp() != null){
			this.txtTimeStamp.setText(dateFormat.format(currentPhoto.getTimeStamp()));
		}else{
			this.txtTimeStamp.setText("null");
		}
		if (currentPhoto.getWidth() != 0){
			this.txtWidth.setText(Integer.toString(currentPhoto.getWidth()));
		}else{
			this.txtWidth.setText("null");
		}
		if (currentPhoto.getHeigh() != 0){
			this.txtHeigh.setText(Integer.toString(currentPhoto.getHeigh()));
		}else{
			this.txtHeigh.setText("null");
		}
		if (currentPhoto.getLatitude() != null){
			this.txtLatitude.setText(Double.toString(currentPhoto.getLatitude()));
		}else{
			this.txtLatitude.setText("null");
		}
		if (currentPhoto.getLongitude() != null){
			this.txtLongitude.setText(Double.toString(currentPhoto.getLongitude()));
		}else{
			this.txtLongitude.setText("null");
		}
	}
}
